The present invention relates to a method for optimizing character string processing. The present invention particularly relates to a method for optimizing executions of a plurality of character string output instructions included in a program.
Java Server Pages (JSP) and Hypertext Processor (PHP) are techniques for dynamically generating a character string to be displayed on a web page. In such techniques, a program for displaying a character string is previously created, and is embedded in a web server. In response to each request from a web-page audience, the program is executed, and thereby a web page responding to the request of the audience is dynamically generated and displayed each time. The main internal operation is processing where an installed program is converted into a program in Java language or the like, and where the converted program is then compiled to be executed (Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both).
A character code set of characters used in a Java language processing system is sometimes different from a character code set of characters to be displayed on a web page. For example, in the case of Java, a character code set of characters stored in a character string variable is Unicode. Unicode is different from Shift JIS that is generally used for a web page. For this reason, in a Java program, after performing a string operation in Unicode, it is necessary to convert a character string from the Unicode character code set to the Shift JIS character code set when outputting the character string. If such conversion processing between character code sets is frequently performed, the efficiency in processing may be reduced.
For the purpose of dealing with the above-described problem, proposed are techniques for improving efficiency in conversion processing between character code sets (refer to Japanese Patent Application Laid-open Publication No. 2005-332146 and Products top page, WebMacro, Website URL: “HTTP://www.webmacro.org/” (hereinafter, referred to as WebMacro). In the technique of WebMacro, a character string before a conversion and a character string after the conversion are cached in association with each other. Thereafter, next time the same character string is converted, the content in the cache is outputted by bypassing the conversion processing. On the other hand, in the technique of Japanese Patent Application Laid-open Publication No. 2005-332146, in the case of a character string output instruction for outputting a character string constant, a character string is previously converted at the time of compiling or loading a class. Thereby, conversion processing is bypassed during the execution of the program. Additionally, in the case of a normal JSP, conversion processing is not performed for every character string output instruction in a program. Instead, when an entire text on one web page is fixed, conversion processing is performed on the text at one time. As a result, the number of times of performing conversion processing is reduced, so that the efficiency in processing is improved.
The techniques of Japanese Patent Application Laid-open Publication No. 2005-332146 and WebMacro are effective especially when there are many character string constants. However, when there are many instructions to output the values of character string variables, conversion processing should be performed in many cases whenever these instructions are executed. Thereby, the processing is not efficient. Moreover, previous conversion of a character string constant according to the technique of Japanese Patent Application Laid-open Publication No. 2005-332146 may results in fragmentation of the character string constant to be converted during the execution of a program. The fragmentation requires the character string constant to be converted in a plurality of processing, even though these conversions can be performed at one time in normal JSP processing. In this case, even if the number of character strings is small, the conversion processing takes a certain time. Hence, there is a risk to decrease the efficiency in an execution of a program due to an increase in the number of times of conversion processing.